home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 January / Pcwk0198.iso / Dzieci / SIMPDATA / SIMPMAIN / 00003_paletteManager parent.ls < prev    next >
Encoding:
Text File  |  1996-09-01  |  20.9 KB  |  567 lines

  1. property theType, theCategory, paletteCast, paletteCounter, paletteWidth, totalBanks, currentBank, bookmarkList, bookmarkTotal, bookmarkIndex, paletteDataList, paletteRecord, defaultBgdCast, editPaletteType, previousBankList, showingPreviousPalette, currentPalette, isSoundPalette, kHiliterWidth, kHiliterHeight
  2. global palBkgndSpr, palArrowSpr, palTitleSpr, bookmarkSpr, palAnimeSpr, palHiliteSpr, selectionHiliteSpr, palHoldSpr, palDeleteSpr, volumePanelSpr, volumeSliderSpr, paletteVisibleP, editPaletteP, volumePaletteP
  3.  
  4. on birth me
  5.   set selectionHiliteSpr to 17
  6.   set palBkgndSpr to selectionHiliteSpr + 1
  7.   set palArrowSpr to selectionHiliteSpr + 2
  8.   set palTitleSpr to selectionHiliteSpr + 3
  9.   set bookmarkSpr to selectionHiliteSpr + 3
  10.   set palAnimeSpr to selectionHiliteSpr + 4
  11.   set palHiliteSpr to selectionHiliteSpr + 5
  12.   puppetSprites(selectionSpr, palHiliteSpr, 1)
  13.   set palHoldSpr to palArrowSpr
  14.   set palDeleteSpr to bookmarkSpr
  15.   set volumePanelSpr to palArrowSpr
  16.   set volumeSliderSpr to bookmarkSpr
  17.   set paletteDataList to [#HOM: [#c, #HOM, 1, 2, the number of cast "homer bookmark", the number of cast "homer palette"], #MAR: [#c, #MAR, 1, 2, the number of cast "marge bookmark", the number of cast "marge palette"], #bar: [#c, #bar, 1, 2, the number of cast "bart bookmark", the number of cast "bart palette"], #LIS: [#c, #LIS, 1, 2, the number of cast "lisa bookmark", the number of cast "lisa palette"], #MAG: [#c, #MAG, 1, 2, the number of cast "maggie bookmark", the number of cast "maggie palette"], #CAM: [#c, #BUR, 1, 3, the number of cast "burns bookmark", the number of cast "burns palette"], #PRP: [#p, #fur, 1, 1, the number of cast "props base bookmark", the number of cast "props base palette"], #bgd: [#b, #SCE, 1, 1, the number of cast "backgrounds base bookmark", the number of cast "backgrounds base palette"], #SFX: [#x, #FGD, 1, 1, the number of cast "sfx base bookmark", the number of cast "sfx base palette"], #LOO: [#l, #LOO, 1, 1, the number of cast "sounds base bookmark", the number of cast "sounds base palette"]]
  18.   set previousBankList to [#HOM: [1, 0], #MAR: [1, 0], #bar: [1, 0], #LIS: [1, 0], #MAG: [1, 0], #CAM: [1, 0], #PRP: [1, 0], #bgd: [1, 0], #SFX: [1, 0], #LOO: [1, 0]]
  19.   set defaultBgdCast to the number of cast "default palette background"
  20.   set bookmarkList to [:]
  21.   set showingPreviousPalette to 0
  22.   set paletteVisibleP to 0
  23.   set editPaletteP to 0
  24.   set volumePaletteP to 0
  25.   return me
  26. end
  27.  
  28. on showPalette me, whichPalette
  29.   set currentPalette to whichPalette
  30.   if (whichPalette = #FullEdit) or (whichPalette = #partialEdit) then
  31.     showEditPalette(me, whichPalette)
  32.   else
  33.     if whichPalette = #volume then
  34.       showVolumeControl(me)
  35.     else
  36.       set the locH of sprite palHiliteSpr to -1000
  37.       showContentPalette(me, whichPalette)
  38.     end if
  39.   end if
  40.   set paletteVisibleP to 1
  41.   set paletteCounter to 1
  42.   updateStage()
  43. end
  44.  
  45. on showContentPalette me, whichPalette
  46.   set editPaletteP to 0
  47.   set volumePaletteP to 0
  48.   if whichPalette = #LOO then
  49.     set isSoundPalette to 1
  50.     set kHiliterWidth to 91 + 2
  51.     set kHiliterHeight to 58 / 2
  52.   else
  53.     set isSoundPalette to 0
  54.     set kHiliterWidth to 47
  55.     set kHiliterHeight to 58
  56.   end if
  57.   set the castNum of sprite palArrowSpr to the number of cast "palette scroll arrows"
  58.   set the rect of sprite palArrowSpr to the rect of cast "palette scroll arrows"
  59.   set the rect of sprite palTitleSpr to the rect of cast "palette title reference"
  60.   set the locV of sprite palArrowSpr to 92
  61.   set the locV of sprite palTitleSpr to 92
  62.   set bookmarkList to [:]
  63.   set the castNum of sprite palBkgndSpr to defaultBgdCast
  64.   set paletteRecord to getaProp(paletteDataList, whichPalette)
  65.   set theType to getAt(paletteRecord, 1)
  66.   set theCategory to getAt(paletteRecord, 2)
  67.   set currentBank to getAt(paletteRecord, 3)
  68.   set totalBanks to getAt(paletteRecord, 4)
  69.   if theType = #c then
  70.     set paletteCast to getAt(paletteRecord, 6) + ((currentBank - 1) * 4)
  71.   else
  72.     set paletteCast to getAt(paletteRecord, 6) + (currentBank - 1)
  73.   end if
  74.   set the castNum of sprite palAnimeSpr to paletteCast
  75.   set paletteWidth to the width of cast paletteCast
  76.   set the width of sprite palAnimeSpr to paletteWidth
  77.   set the locH of sprite palBkgndSpr to 313
  78.   set the locH of sprite palArrowSpr to 313
  79.   set the locH of sprite palTitleSpr to 313
  80.   set the locH of sprite palAnimeSpr to 313
  81.   if theType = #c then
  82.     if whichPalette = #CAM then
  83.       set bookmarkList to [#BUR: 3, #KRU: 2, #CAM: 2]
  84.     else
  85.       setaProp(bookmarkList, theCategory, totalBanks)
  86.     end if
  87.     showTitlePalette()
  88.   else
  89.     if theType = #p then
  90.       set bookmarkList to [#fur: 1, #APP: 1, #foo: 1, #PLA: 1, #ANI: 1, #IND: 1, #MIS: 1, #PPC: 1]
  91.       showBookmarkPalette()
  92.     else
  93.       if theType = #x then
  94.         set bookmarkList to [#FGD: 1, #TRA: 1, #end: 1, #bgd: 1]
  95.         showBookmarkPalette()
  96.       else
  97.         if theType = #b then
  98.           set bookmarkList to [#SCE: 1]
  99.           showBookmarkPalette()
  100.         else
  101.           if (theType = #n) or (theType = #l) then
  102.             set bookmarkList to [#LOO: 1, #VOS: 5, #HUM: 2]
  103.             showBookmarkPalette()
  104.           end if
  105.         end if
  106.       end if
  107.     end if
  108.   end if
  109.   showPreviousPalette(me, whichPalette)
  110. end
  111.  
  112. on showPreviousPalette me, whichPalette
  113.   set previousPalette to getaProp(previousBankList, whichPalette)
  114.   if getAt(previousPalette, 2) <> 0 then
  115.     if getAt(previousPalette, 1) <> 0 then
  116.       repeat with i = 1 to getAt(previousPalette, 1) - 1
  117.         switchBank("right")
  118.       end repeat
  119.     end if
  120.     repeat with i = 1 to 4
  121.       startTimer()
  122.       set showingPreviousPalette to 1
  123.       set the locH of sprite palHiliteSpr to -1000
  124.       updateStage()
  125.       repeat while the timer < 6
  126.       end repeat
  127.       hilite(me, getAt(previousPalette, 2))
  128.       updateStage()
  129.       repeat while the timer < 6
  130.       end repeat
  131.     end repeat
  132.   end if
  133. end
  134.  
  135. on showEditPalette me, whichPalette
  136.   set editPaletteP to 1
  137.   set volumePaletteP to 0
  138.   set editPaletteType to whichPalette
  139.   set the castNum of sprite palBkgndSpr to defaultBgdCast
  140.   set the locH of sprite palBkgndSpr to 313
  141.   if whichPalette = #FullEdit then
  142.     set the castNum of sprite palHoldSpr to the number of cast "hold palette"
  143.     set the castNum of sprite palDeleteSpr to the number of cast "delete palette"
  144.   else
  145.     set the castNum of sprite palHoldSpr to the number of cast "partial hold palette"
  146.     set the castNum of sprite palDeleteSpr to the number of cast "partial delete palette"
  147.   end if
  148.   set the rect of sprite palHoldSpr to the rect of cast "hold palette"
  149.   set the locH of sprite palHoldSpr to 313
  150.   set the locV of sprite palHoldSpr to 100
  151.   set the rect of sprite palDeleteSpr to the rect of cast "delete palette"
  152.   set the locH of sprite palDeleteSpr to 313
  153.   set the locV of sprite palDeleteSpr to 180
  154.   set editPaletteP to 1
  155. end
  156.  
  157. on showVolumeControl me
  158.   set editPaletteP to 0
  159.   set volumePaletteP to 1
  160.   set the castNum of sprite volumePanelSpr to the number of cast "volume panel"
  161.   set the rect of sprite volumePanelSpr to the rect of cast "volume panel"
  162.   set the locH of sprite volumePanelSpr to 313
  163.   set the locV of sprite volumePanelSpr to 150
  164.   updateStage()
  165.   set the castNum of sprite volumeSliderSpr to the number of cast "volume slider"
  166.   set the rect of sprite volumeSliderSpr to the rect of cast "volume slider"
  167.   set the locH of sprite volumeSliderSpr to 280
  168.   set the locV of sprite volumeSliderSpr to 150
  169.   set theVolumeIncrement to 24
  170.   set topOffset to 22
  171.   set volumePanelMinV to the top of sprite volumePanelSpr + topOffset
  172.   set the locV of sprite volumeSliderSpr to volumePanelMinV + ((6 - getCurrentSoundLevel(appMgr)) * theVolumeIncrement)
  173. end
  174.  
  175. on showTitlePalette
  176.   set bookmarkTotal to count(bookmarkList)
  177.   set bookmarkIndex to 1
  178.   set theTitleCast to getAt(paletteRecord, 5)
  179.   set the castNum of sprite palTitleSpr to theTitleCast
  180.   set the locH of sprite palTitleSpr to the locH of sprite palBkgndSpr
  181.   set the width of sprite palTitleSpr to the width of cast theTitleCast
  182.   set the height of sprite palTitleSpr to the height of cast theTitleCast
  183. end
  184.  
  185. on showBookmarkPalette
  186.   set bookmarkTotal to count(bookmarkList)
  187.   set bookmarkIndex to 1
  188.   set bookmarkCast to getAt(paletteRecord, 5)
  189.   set the castNum of sprite bookmarkSpr to bookmarkCast
  190.   set the locH of sprite bookmarkSpr to the locH of sprite palBkgndSpr
  191.   set the width of sprite bookmarkSpr to the width of cast bookmarkCast
  192.   set the height of sprite bookmarkSpr to the height of cast bookmarkCast
  193. end
  194.  
  195. on hidePalette me
  196.   unLoadCast(231, 236)
  197.   if currentPalette = #HOM then
  198.     unLoadCast(341, 349)
  199.   else
  200.     if currentPalette = #MAR then
  201.       unLoadCast(351, 359)
  202.     else
  203.       if currentPalette = #bar then
  204.         unLoadCast(361, 369)
  205.       else
  206.         if currentPalette = #LIS then
  207.           unLoadCast(371, 379)
  208.         else
  209.           if currentPalette = #MAG then
  210.             unLoadCast(381, 389)
  211.           else
  212.             if currentPalette = #CAM then
  213.               unLoadCast(391, 421)
  214.             else
  215.               if currentPalette = #PRP then
  216.                 unLoadCast(461, 476)
  217.               else
  218.                 if currentPalette = #bgd then
  219.                   unLoadCast(451, 452)
  220.                 else
  221.                   if currentPalette = #SFX then
  222.                     unLoadCast(431, 450)
  223.                   else
  224.                     if currentPalette = #LOO then
  225.                       unLoadCast(841, 944)
  226.                     else
  227.                       if currentPalette = #FullEdit then
  228.                         unLoadCast(237, 238)
  229.                       else
  230.                         if currentPalette = #partialEdit then
  231.                           unLoadCast(239, 240)
  232.                         else
  233.                           if currentPalette = #volume then
  234.                             unLoadCast(218, 219)
  235.                           end if
  236.                         end if
  237.                       end if
  238.                     end if
  239.                   end if
  240.                 end if
  241.               end if
  242.             end if
  243.           end if
  244.         end if
  245.       end if
  246.     end if
  247.   end if
  248.   set the locH of sprite palBkgndSpr to -1000
  249.   set the locH of sprite palArrowSpr to -1000
  250.   set the locH of sprite palTitleSpr to -1000
  251.   set the locH of sprite palAnimeSpr to -1000
  252.   set the locH of sprite palHiliteSpr to -1000
  253.   set the locH of sprite selectionHiliteSpr to -1000
  254.   resetPanel(interfaceMgr)
  255.   puppetSound(1, 0)
  256.   puppetSound(2, 0)
  257.   updateStage()
  258.   set paletteVisibleP to 0
  259. end
  260.  
  261. on animate me
  262.   if rollOver(palAnimeSpr) then
  263.     set showingPreviousPalette to 0
  264.     hilite(me, 0)
  265.   else
  266.     if not showingPreviousPalette then
  267.       set the locH of sprite palHiliteSpr to -1000
  268.     end if
  269.   end if
  270.   if (theType = #c) or (theType = #x) then
  271.     if paletteCounter < 4 then
  272.       set the castNum of sprite palAnimeSpr to the castNum of sprite palAnimeSpr + 1
  273.       set paletteCounter to paletteCounter + 1
  274.     else
  275.       set the castNum of sprite palAnimeSpr to paletteCast
  276.       set paletteCounter to 1
  277.     end if
  278.   end if
  279.   updateStage()
  280. end
  281.  
  282. on hilite me, theColumn
  283.   if isSoundPalette then
  284.     set palettePictH to the left of sprite palAnimeSpr - 1
  285.     set palettePictV to the top of sprite palAnimeSpr
  286.     if theColumn = 0 then
  287.       set col to (the mouseH - palettePictH) / kHiliterWidth
  288.       set row to (the mouseV - palettePictV) / kHiliterHeight
  289.     else
  290.       set col to theColumn - 5 + (5 * (theColumn <= 5)) - 1
  291.       set row to 0 > (5 - theColumn)
  292.     end if
  293.     set posH to palettePictH + (col * kHiliterWidth)
  294.     set the locH of sprite palHiliteSpr to posH - col
  295.     set posV to palettePictV + (row * kHiliterHeight)
  296.     set the locV of sprite palHiliteSpr to posV
  297.     set the width of sprite palHiliteSpr to kHiliterWidth
  298.     set the height of sprite palHiliteSpr to kHiliterHeight
  299.   else
  300.     set palettePictH to the left of sprite palAnimeSpr - 1
  301.     if theColumn = 0 then
  302.       set col to (the mouseH - palettePictH) / kHiliterWidth
  303.     else
  304.       set col to theColumn - 1
  305.     end if
  306.     set posH to palettePictH + (col * kHiliterWidth)
  307.     set the locH of sprite palHiliteSpr to posH - col
  308.     set the locV of sprite palHiliteSpr to the top of sprite palAnimeSpr
  309.     set the width of sprite palHiliteSpr to kHiliterWidth
  310.     set the height of sprite palHiliteSpr to kHiliterHeight
  311.   end if
  312. end
  313.  
  314. on visibleP me
  315.   return paletteVisibleP
  316. end
  317.  
  318. on handleBtn me, theSpr, theMouseH, theMouseV
  319.   if theSpr <> palBkgndSpr then
  320.     if editPaletteP then
  321.       editPaletteClick(me, theSpr, theMouseH)
  322.     else
  323.       if volumePaletteP then
  324.         volumePaletteClick(me, theSpr, theMouseH, theMouseV)
  325.       else
  326.         contentPaletteClick(me, theSpr, theMouseH, theMouseV)
  327.       end if
  328.     end if
  329.   end if
  330. end
  331.  
  332. on editPaletteClick me, theSpr, theMouseH
  333.   cursor(4)
  334.   set theInterval to the width of sprite theSpr / 3
  335.   set theClickLocH to theMouseH - the left of sprite theSpr
  336.   hidePalette(me)
  337.   if theSpr = palHoldSpr then
  338.     if editPaletteType = #FullEdit then
  339.       set actionList to ["holdClip(editMgr, -1)", "holdClip(editMgr,0)", "holdClip(editMgr, 1)"]
  340.     else
  341.       set actionList to ["nothing", "nothing", "nothing"]
  342.     end if
  343.   else
  344.     if theSpr = palDeleteSpr then
  345.       if editPaletteType = #FullEdit then
  346.         set actionList to ["deleteClip(editMgr,-1)", "deleteClip(editMgr,0)", "deleteClip(editMgr,1)"]
  347.       else
  348.         set actionList to ["nothing", "deleteClip(editMgr,0)", "nothing"]
  349.       end if
  350.     else
  351.       if theSpr = palHiliteSpr then
  352.         exit
  353.       end if
  354.     end if
  355.   end if
  356.   if theClickLocH < theInterval then
  357.     do(getAt(actionList, 1))
  358.   else
  359.     if theClickLocH < (theInterval * 2) then
  360.       do(getAt(actionList, 2))
  361.     else
  362.       do(getAt(actionList, 3))
  363.     end if
  364.   end if
  365.   cursor(-1)
  366. end
  367.  
  368. on volumePaletteClick me, theSpr, theMouseH, theMouseV
  369.   set theVolumeIncrement to 24
  370.   set topOffset to 22
  371.   set bottomOffset to 22
  372.   set volumePanelMinV to the top of sprite volumePanelSpr + topOffset
  373.   set volumePanelMaxV to the bottom of sprite volumePanelSpr - bottomOffset
  374.   if theSpr = volumeSliderSpr then
  375.     repeat while the mouseDown
  376.       if (the mouseV > volumePanelMinV) and (the mouseV < volumePanelMaxV) then
  377.         set volumePosition to (the mouseV - volumePanelMinV) / theVolumeIncrement
  378.         set newPosV to volumePanelMinV + (volumePosition * theVolumeIncrement)
  379.         if newPosV <> the locV of sprite volumeSliderSpr then
  380.           changeVolume(appMgr, 6 - volumePosition)
  381.           puppetSound("pop snd")
  382.           set the locV of sprite volumeSliderSpr to newPosV
  383.         end if
  384.       else
  385.         if the mouseV < volumePanelMinV then
  386.           if the locV of sprite volumeSliderSpr <> volumePanelMinV then
  387.             changeVolume(appMgr, 6)
  388.             puppetSound("pop snd")
  389.             set the locV of sprite volumeSliderSpr to volumePanelMinV
  390.           end if
  391.         else
  392.           if the mouseV > volumePanelMaxV then
  393.             if the locH of sprite volumeSliderSpr <> volumePanelMaxV then
  394.               changeVolume(appMgr, 0)
  395.               puppetSound("pop snd")
  396.               set the locV of sprite volumeSliderSpr to volumePanelMaxV
  397.             end if
  398.           end if
  399.         end if
  400.       end if
  401.       updateStage()
  402.     end repeat
  403.   else
  404.     if theSpr = volumePanelSpr then
  405.       set btnBoundsLst to value(line 1 of field "volPalData")
  406.       set theMouseH to theMouseH - the left of sprite theSpr
  407.       set theMouseV to theMouseV - the top of sprite theSpr
  408.       set theMouseLoc to point(theMouseH, theMouseV)
  409.       repeat with buttonNum = 1 to count(btnBoundsLst)
  410.         set theButtonBounds to getAt(btnBoundsLst, buttonNum)
  411.         if inside(theMouseLoc, theButtonBounds) then
  412.           set volumePosition to (buttonNum * 2) - 2
  413.           set newPosV to volumePanelMinV + (volumePosition * theVolumeIncrement)
  414.           if newPosV <> the locV of sprite volumeSliderSpr then
  415.             changeVolume(appMgr, 6 - volumePosition)
  416.             puppetSound("pop snd")
  417.             set the locV of sprite volumeSliderSpr to newPosV
  418.             updateStage()
  419.             startTimer()
  420.             repeat while the timer < 6
  421.             end repeat
  422.           end if
  423.           exit repeat
  424.         end if
  425.       end repeat
  426.     end if
  427.   end if
  428. end
  429.  
  430. on contentPaletteClick me, theSpr, theMouseH, theMouseV
  431.   if theSpr = palArrowSpr then
  432.     set showingPreviousPalette to 0
  433.     if theMouseH < the locH of sprite palArrowSpr then
  434.       switchBank("left")
  435.     else
  436.       switchBank("right")
  437.     end if
  438.   else
  439.     if theSpr = bookmarkSpr then
  440.       if getOne([#HOM, #MAR, #bar, #LIS, #MAG], currentPalette) = 0 then
  441.         gotoBookmark(theMouseH)
  442.       end if
  443.     else
  444.       if theSpr = palHiliteSpr then
  445.         set paletteIndex to getSelectedClip(theMouseH, theMouseV)
  446.         set ok2Record to 1
  447.         if isSoundPalette then
  448.           if (theMouseH > the left of sprite palHiliteSpr) and (theMouseH < (the left of sprite palHiliteSpr + 27)) and ((theMouseV > the top of sprite palHiliteSpr) and (theMouseV < (the top of sprite palHiliteSpr + 24))) then
  449.             set ok2Record to 0
  450.             previewSound(playbackMgr, theCategory, currentBank, paletteIndex)
  451.           end if
  452.         end if
  453.         repeat while the mouseDown
  454.         end repeat
  455.         if ok2Record then
  456.           hidePalette()
  457.           set bankOffset to 0
  458.           if bookmarkIndex <> 1 then
  459.             repeat with theIndex = 1 to bookmarkIndex - 1
  460.               set bankOffset to bankOffset + getAt(bookmarkList, theIndex)
  461.             end repeat
  462.           end if
  463.           setaProp(previousBankList, currentPalette, [bankOffset + currentBank, paletteIndex])
  464.           recordClip(recordMgr, theCategory, currentBank, paletteIndex)
  465.         end if
  466.       end if
  467.     end if
  468.   end if
  469. end
  470.  
  471. on getSelectedClip thePosH, thePosV
  472.   if isSoundPalette then
  473.     set theColumn to ((thePosH - the left of sprite palAnimeSpr) / kHiliterWidth) + 1
  474.     set theRow to ((thePosV - the top of sprite palAnimeSpr) / kHiliterHeight) + 1
  475.     return theColumn + (5 * (theRow - 1))
  476.   else
  477.     return ((thePosH - the left of sprite palAnimeSpr) / kHiliterWidth) + 1
  478.   end if
  479. end
  480.  
  481. on gotoBookmark theMouseH
  482.   set bookmarkButtonWidth to (the width of sprite bookmarkSpr / bookmarkTotal) + 2
  483.   set bookmarkSprH to the left of sprite bookmarkSpr
  484.   set bookmarkIndex to ((the mouseH - bookmarkSprH) / bookmarkButtonWidth) + 1
  485.   switchBank(bookmarkIndex)
  486. end
  487.  
  488. on switchBank direction
  489.   set the locH of sprite palHiliteSpr to -1000
  490.   if direction = "right" then
  491.     if currentBank < totalBanks then
  492.       set currentBank to currentBank + 1
  493.     else
  494.       if bookmarkIndex < bookmarkTotal then
  495.         set currentBank to 1
  496.         set bookmarkIndex to bookmarkIndex + 1
  497.         set theCategory to getPropAt(bookmarkList, bookmarkIndex)
  498.         set totalBanks to getaProp(bookmarkList, theCategory)
  499.       else
  500.         set currentBank to 1
  501.         set bookmarkIndex to 1
  502.         set theCategory to getPropAt(bookmarkList, bookmarkIndex)
  503.         set totalBanks to getaProp(bookmarkList, theCategory)
  504.       end if
  505.     end if
  506.   else
  507.     if direction = "left" then
  508.       if currentBank > 1 then
  509.         set currentBank to currentBank - 1
  510.       else
  511.         if bookmarkIndex > 1 then
  512.           set bookmarkIndex to bookmarkIndex - 1
  513.           set theCategory to getPropAt(bookmarkList, bookmarkIndex)
  514.           set totalBanks to getaProp(bookmarkList, theCategory)
  515.           set currentBank to totalBanks
  516.         else
  517.           set bookmarkIndex to bookmarkTotal
  518.           set theCategory to getPropAt(bookmarkList, bookmarkIndex)
  519.           set totalBanks to getaProp(bookmarkList, theCategory)
  520.           set currentBank to totalBanks
  521.         end if
  522.       end if
  523.     else
  524.       if integerp(direction) then
  525.         set theCategory to getPropAt(bookmarkList, direction)
  526.         set totalBanks to getaProp(bookmarkList, theCategory)
  527.         set currentBank to 1
  528.       end if
  529.     end if
  530.   end if
  531.   set bookmarkCast to getAt(paletteRecord, 5) + (bookmarkIndex - 1)
  532.   set the castNum of sprite bookmarkSpr to the number of cast bookmarkCast
  533.   set the width of sprite bookmarkSpr to the width of cast bookmarkCast
  534.   set the height of sprite bookmarkSpr to the height of cast bookmarkCast
  535.   if theType = #c then
  536.     set bankOffset to 0
  537.     if bookmarkIndex <> 1 then
  538.       repeat with theIndex = 1 to bookmarkIndex - 1
  539.         set bankOffset to bankOffset + getAt(bookmarkList, theIndex)
  540.       end repeat
  541.     end if
  542.     set paletteCast to getAt(paletteRecord, 6) + ((currentBank - 1 + bankOffset) * 4)
  543.   else
  544.     if theType = #x then
  545.       set bankOffset to 0
  546.       if bookmarkIndex <> 1 then
  547.         repeat with theIndex = 1 to bookmarkIndex - 1
  548.           set bankOffset to bankOffset + getAt(bookmarkList, theIndex)
  549.         end repeat
  550.       end if
  551.       set paletteCast to getAt(paletteRecord, 6) + ((currentBank - 1 + bankOffset) * 4)
  552.     else
  553.       set bankOffset to 0
  554.       if bookmarkIndex <> 1 then
  555.         repeat with theIndex = 1 to bookmarkIndex - 1
  556.           set bankOffset to bankOffset + getAt(bookmarkList, theIndex)
  557.         end repeat
  558.       end if
  559.       set paletteCast to getAt(paletteRecord, 6) + (currentBank - 1) + bankOffset
  560.     end if
  561.   end if
  562.   set the castNum of sprite palAnimeSpr to paletteCast
  563.   set paletteWidth to the width of cast paletteCast
  564.   set the width of sprite palAnimeSpr to paletteWidth
  565.   set paletteCounter to 1
  566. end
  567.